// 弹窗控制函数
function openConsultationModal() {
  document.getElementById("consultationModal").classList.add("show");
  document.body.style.overflow = "hidden"; // 防止背景滚动
}

function closeConsultationModal() {
  document.getElementById("consultationModal").classList.remove("show");
  document.body.style.overflow = "auto"; // 恢复背景滚动
}

// 点击遮罩层关闭弹窗
document
  .getElementById("consultationModal")
  .addEventListener("click", function (e) {
    if (e.target === this) {
      closeConsultationModal();
    }
  });

// ESC键关闭弹窗
document.addEventListener("keydown", function (e) {
  if (
    e.key === "Escape" &&
    document.getElementById("consultationModal").classList.contains("show")
  ) {
    closeConsultationModal();
  }
});
// 电话号码验证
function validatePhoneNumber(phone) {
  const phoneRegex = /^1[3-9]\d{9}$|^0\d{2,3}-?\d{7,8}$|^400-?\d{3}-?\d{4}$/;
  return phoneRegex.test(phone);
}
